package com.suns.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Blob;
import java.sql.Date;
import java.sql.Time;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("admin")
public class Admin {
    @TableId(type = IdType.AUTO)
    private Integer id;
    private String tel;
    private String pwd;
    private String name;
    private String time;
    private Integer age;
    private String gender;

    //重写toString 方法,用json序列化框架(Gson),方便将Admin类型数据存储在Cookie中
    @Override
    public String toString() {
        return new Gson().toJson(this);
    }

    // 静态方法，用于将JSON字符串转换成对象
    public static Admin fromJsonString(String json) {
        return new Gson().fromJson(json, Admin.class);
    }
}
